﻿using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;

namespace Pay.Service.AutoMapper {
	public class GradeMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public GradeMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {
			_cfg.CreateMap<grade_dto, Grade>()
				.ForMember(dest => dest.MerchantNo, src => src.MapFrom(c => c.merchant_no))
				.ForMember(dest => dest.GradeNo, src => src.MapFrom(c => c.grade_no));
			_cfg.CreateMap<Grade, grade_dto>()
				.ForMember(dest => dest.merchant_no, src => src.MapFrom(c => c.MerchantNo))
				.ForMember(dest => dest.grade_no, src => src.MapFrom(c => c.GradeNo))
				.ForMember(dest => dest.payments, src => src.MapFrom(c => c.MerchantPayments));
		}
	}
}
